package com.inews.business.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 系统资源角色对应实体.
 */
@Entity
@Table(name="tbl_sys_role_resource")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class TblSysRoleResource {
	
	/** The version. */
	private Long version;
	
	/** 资源角色Id. */
	private Long roleResourceId;
	
	/** 对应角色. */
	private TblSysRole role;
	
	/** 对应资源. */
	private TblSysResource resource;
	
	
	public TblSysRoleResource() {
		super();
	}

	public TblSysRoleResource(TblSysRole role, TblSysResource resource) {
		this.role = role;
		this.resource = resource;
	}

	@Version
	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getRoleResourceId() {
		return roleResourceId;
	}

	public void setRoleResourceId(Long roleResourceId) {
		this.roleResourceId = roleResourceId;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, optional=false)    
	@JoinColumn(name="role_id")
	public TblSysRole getRole() {
		return role;
	}

	public void setRole(TblSysRole role) {
		this.role = role;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, optional=false)    
	@JoinColumn(name="resource_id")
	public TblSysResource getResource() {
		return resource;
	}

	public void setResource(TblSysResource resource) {
		this.resource = resource;
	}
	
	
}
